package com.sld.concrete.algorithm.service.impl;

import com.ruoyi.common.annotation.DataScope;
import com.sld.concrete.algorithm.domain.RecDevCalculate;
import com.sld.concrete.algorithm.mapper.RecDevCalculateMapper;
import com.sld.concrete.algorithm.service.IRecCalcDataService;
import com.sld.concrete.algorithm.vo.WorkDataInfo;
import com.sld.concrete.device.domain.RecDevMessage;
import com.sld.concrete.device.mapper.RecDevMessageMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RecDataCalcServiceImpl implements IRecCalcDataService {

    @Resource
    RecDevCalculateMapper calculateMapper;

    @Resource
    RecDevMessageMapper recDevMessageMapper;


    @Override
    @DataScope(deptAlias = "d")
    public List<WorkDataInfo> queryWorkData(WorkDataInfo workDataInfo) {
        return calculateMapper.queryWorkData(workDataInfo);
    }

    @Override
    public List<RecDevMessage> queryCalculateMetaData(String calcId) {
        RecDevCalculate recDevCalculate = calculateMapper.selectRecDevCalculateById(Long.parseLong(calcId));
        if (recDevCalculate == null) {
            return null;
        }
        String msgIds = recDevCalculate.getMsgIds();
        return recDevMessageMapper.selectRecDevMessageByMsgIds(msgIds.split(","));
    }
}
